from django.template import loader
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect

# Create your views here.


def rebuild_info(segment, state_info):
    res = ""
    if segment == "new_task":
        if state_info == "success":
            res = "工单创建成功！"
    return res


# @login_required(login_url="/login/")
def pages(request):
    context = {}
    path_list = request.get_full_path().split("/")
    context["segment"] = path_list[-2]
    context["state_info"] = rebuild_info(context["segment"], path_list[-1])

    print(f'segment_name: {context["segment"]}, state_info: {context["state_info"]}')

    html_template = loader.get_template("info/info.html")

    return HttpResponse(html_template.render(context, request))
